package es.efor.ics.gev.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * The persistent class for the <b>FICHAS_CONOCIMIENTO</b> database table. 
 * 
 * @see Evento#addFichaConocimiento(FichaConocimiento)
 * @author dlisbona
 *
 */
@Entity
@Table(name = "FICHAS_CONOCIMIENTO")
public class FichaConocimiento extends BaseObject implements Serializable {
	
	// static data
	private static final long serialVersionUID = 2008154046569580240L;
	
	// private instance data
	private Long id;
	private Evento evento;
	private Integer version;	
	
	/**
	 * Construct an uninitialized <code>FichaConocimiento</code> (for runtime proxy
	 * generation in Hibernate).
	 */
	public FichaConocimiento() {		
	}
	
	// ********************** Accessor Methods ********************** //
	
	@Id
	@Column(name = "FICHA_EVENTO_ID")
	@GeneratedValue(generator = "foreign")
	@GenericGenerator(
			name = "foreign", 
			strategy = "foreign", 
			parameters = { 
					@Parameter(
							name = "property", 
							value = "evento") })
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@OneToOne(mappedBy="fichaConocimiento", optional=false, fetch=FetchType.LAZY)
	public Evento getEvento() {
		return evento;
	}
	
	public void setEvento(Evento evento) {
		this.evento = evento;
	}

	@Version
	@Column(name = "OBJ_VERSION")
	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	// ********************** Common Methods ********************** //	
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof FichaConocimiento == false) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		FichaConocimiento rhs = (FichaConocimiento) obj;	
		// TODO Auto-generated method stub
		return EqualsBuilder.reflectionEquals(this, rhs);
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
    public String toString() {
		// TODO Auto-generated method stub
      return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
    } 	
	
}
